<template>
    <div>

    </div>
</template>

<script>
    import { getLift, getGreenBuilding, getCameraImage, getTrafficSpeed, getBridge, getCampus, getFlood, } from '@/api/data';
    import { SetCameraInfo, AddCustom_POI, AddPOI } from '@/util/poi'
    import { delay } from '@/util/date'
    export default {
        name: 'CAMPUS',
        props: [''],
        data() {
            return {
                campusList: []
            };
        },

        components: {},

        computed: {},

        beforeMount() {},

        async mounted() {
            this.campusList = await getCampus();
            this.addPoi()

            this.setCameraFocusCampus()

            console.log(this.campusList, '1111111');
        },

        methods: {
            //增加pol点
            async addPoi() {
                let removeJsondata = {
                    "covering_type": "poi" //覆盖物类型, 详见下表
                }
                window.cloudRender.SuperAPI("RemoveAllCovering", removeJsondata);
                // 循环打点
                if (Array.isArray(this.campusList.Campus) && this.campusList.Campus.length > 1) {
                    for (let i = 0; i < this.campusList.Campus.length; i++) {
                        let html = location.origin + '/html/campus.html?content=' + JSON.stringify(this.campusList.Campus[i])
                        let { guid, lon, lat, imageurl } = this.campusList.Campus[i];
                        let jsondata = AddCustom_POI(guid, lon + ',' + lat, html);
                        window.cloudRender.SuperAPI("AddCustomPOI", jsondata, (status, progress) => {
                            console.log(status, progress, '加入poi点第', i);
                        })
                    }
                }
            },
            // 镜头聚焦campus
            async setCameraFocusCampus() {
                window.cloudRender.SuperAPI("ResetCamera", { "state": "default" })
                let filterArr = this.campusList.Campus.filter(it => {
                    return it.title == 'Surbana Jurong Campus'
                })
                let lonLat = filterArr[0].lon + ',' + filterArr[0].lat
                await delay(200)
                //设置当前镜头视界
                let jsondata = SetCameraInfo(lonLat, 300, 40)
                window.cloudRender.SuperAPI("SetCameraInfo", jsondata)
                await delay(1200)
                // 绕中心点旋转
                window.cloudRender.SuperAPI("SetCameraRotate", {
                    "time": 100,
                    "direction": "anticlockwise"
                })
            }
        },

        watch: {}

    }
</script>
<style lang='' scoped>

</style>